package controller

import (
	"mini-app/internal/app/web/service"

	"192.168.1.75/go-pkg/response"

	"github.com/gin-gonic/gin"
)

type AdConfig struct{}

// SetBasePrice 设置广告基础价格
func (AdConfig) SetBasePrice(c *gin.Context) {
	var params struct {
		BasePrice float32 `json:"base_price"`
	}
	c.ShouldBindJSON(&params)

	err := service.AdConfig{}.SetBasePrice(c.Request.Context(), params.BasePrice)
	response.JSON(c, gin.H{}, err)
}

// GetBasePrice 获取广告基础价格
func (AdConfig) GetBasePrice(c *gin.Context) {
	basePrice, err := service.AdConfig{}.GetBasePrice(c.Request.Context())
	response.JSON(c, gin.H{
		"base_price": basePrice,
	}, err)
}

func (AdConfig) SetSearchRadius(c *gin.Context) {
	var params struct {
		SearchRadius float32 `json:"search_radius"`
	}
	c.ShouldBindJSON(&params)

	err := service.AdConfig{}.SetSearchRadius(c.Request.Context(), params.SearchRadius)
	response.JSON(c, gin.H{}, err)
}

// GetBasePrice 获取广告基础价格
func (AdConfig) GetSearchRadius(c *gin.Context) {
	search_radius, err := service.AdConfig{}.GetSearchRadius(c.Request.Context())
	response.JSON(c, gin.H{
		"search_radius": search_radius,
	}, err)
}
